<%@ page import="java.util.Map" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>电影列表</title>
    <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="container mx-auto p-4">
    <h2 class="text-2xl font-bold mb-4">电影列表</h2>
    <table class="w-full border-collapse">
        <thead>
        <tr>
            <th class="px-4 py-2 bg-gray-100 border-b">ID</th>
            <th class="px-4 py-2 bg-gray-100 border-b">名称</th>
            <th class="px-4 py-2 bg-gray-100 border-b">类型</th>
            <th class="px-4 py-2 bg-gray-100 border-b">简介</th>
        </tr>
        </thead>
        <tbody>
        <%
            // 创建电影列表数据
            List<Map<String, String>> movieList = new ArrayList<>();

            movieList.add(Map.of(
                    "id", "5452",
                    "name", "你将不再孤单",
                    "genre", "nijiangbuzaigudan",
                    "remarks", "焦点影业拿下超自然恐怖片You Won’t Be Alone全球发行权。该片卡司包括劳米·拉佩斯、安娜玛丽亚·玛琳卡(《火星时代》)、爱丽丝·恩格勒特([美丽生灵])、卡里托·科塔([弗兰琪])、费利",
                    "coverImage", "https://suboimage.com/cover/6364d3f0f495b6ab9dcf8d3b5c6e0b01.jpg"
            ));
            movieList.add(Map.of(
                    "id", "9365",
                    "name", "奥林匹斯的陷落",
                    "genre", "aolinpisidexianluo",
                    "remarks", "白宫，特情局秘密代号为“奥林匹斯”，目前正处在危机之中……",
                    "coverImage", "https://suboimage.com/cover/18dc2aa306574480d292c7b0210f7545.jpg"
            ));
            movieList.add(Map.of(
                    "id", "10031",
                    "name", "杀戮战场",
                    "genre", "shaluzhanchang",
                    "remarks", "1972年，美军在越南溃败撤离柬埔寨之后……",
                    "coverImage", "https://suboimage.com/cover/20c8b2aa5b567ae19224040bc52b36f1.jpg"
            ));
            movieList.add(Map.of(
                    "id", "25024",
                    "name", "骇战",
                    "genre", "haizhan",
                    "remarks", "爱情, 科幻, 悬疑",
                    "coverImage", "https://suboimage.com/cover/5b04bd53d09643498576fb2bf876a707.jpg"
            ));
            movieList.add(Map.of(
                    "id", "25237",
                    "name", "再造战士",
                    "genre", "zaizaozhanshi",
                    "remarks", "越战后，美国政府进行了一项绝密的科学计划……",
                    "coverImage", "https://suboimage.com/cover/93106f2b3d83f77dbb5a098e014fad40.jpg"
            ));

            // 将电影列表作为属性传递给 JSP
            request.setAttribute("movieList", movieList);
        %>

        <!-- 使用 JSTL 循环显示电影数据 -->
        <c:forEach var="movie" items="${movieList}">
            <tr class="border-b hover:bg-gray-50">
                <td class="px-4 py-2">${movie.id}</td>
                <td class="px-4 py-2">${movie.name}</td>
                <td class="px-4 py-2">${not empty movie.genre ? movie.genre : '未知类型'}</td>
                <td class="px-4 py-2">${movie.remarks}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html>
